Skip to content

Add array-index support to Parquet variant field extraction#2

Closed
vuule wants to merge 2 commits into
pr2-variant-field-extraction-corefrom
pr3-variant-array-indexing
Closed

Add array-index support to Parquet variant field extraction#2
vuule wants to merge 2 commits into
pr2-variant-field-extraction-corefrom
pr3-variant-array-indexing

Conversation

@vuule

@vuule vuule commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary

Stacked on top of the PR2 branch (rapidsai#22416). Extends the JSONPath-like
path used by get_variant_field / extract_variant_field to descend into VARIANT
array values via zero-based [N] index steps, in addition to the existing
object-key descent.

  • variant_path.cpp: parse [<non-negative integer>] steps, preserving the
    literal [N] token so the GPU-side path walker can distinguish index steps from
    object-key steps by their first byte. [*] wildcards, negative indices, quoted
    names inside [...], and unterminated brackets throw std::invalid_argument.
  • variant_extract.cu: add locate_array_element (parses the array value
    header — num_elements + offsets — and returns the N-th element's subspan) and
    dispatch on a leading [ in resolve_path.
  • variant.hpp: document the extended path grammar and array-indexing behavior
    (e.g. "$[0]", "$.a[0].b").
  • Tests: positive int8 array indexing, out-of-bounds / type-mismatch nulls, and
    an updated SyntaxErrors case (now accepts "$.a[0]", still rejects "$.a[-1]",
    "$.a[1", "$.a[*]", ...).

Notes for reviewers

Next PR in the VARIANT extraction stack (rapidsai#22310 merged -> rapidsai#22416 -> this). Base is
pr2-variant-field-extraction-core; retarget to main once rapidsai#22416 merges. Diff is
array-indexing only - the binary-search metadata optimization from the feature
branch is intentionally not included here and will land separately.

Test plan

  • VARIANT_EXTRACT_TEST builds and passes locally (33/33), including the new
    array-indexing tests.
  • CI green.

Made with Cursor

Extend the JSONPath-like path used by get_variant_field/extract_variant_field
to descend into array values via zero-based "[N]" steps, in addition to the
existing object-key descent.

- variant_path.cpp: parse "[<non-negative integer>]" steps, preserving the
  literal "[N]" token so the GPU path walker can distinguish index steps from
  object-key steps by their first byte. Wildcards ("[*]"), negative indices,
  quoted names in brackets, and unterminated brackets throw.
- variant_extract.cu: add locate_array_element (parses the array value header
  and returns the N-th element's subspan) and dispatch on "[" in resolve_path.
- variant.hpp: document the extended path grammar and array-indexing behavior.
- Tests: positive int8 array indexing, out-of-bounds / type-mismatch nulls, and
  updated SyntaxErrors to accept "$.a[0]" while rejecting "$.a[-1]" and "$.a[1".

Verified locally: VARIANT_EXTRACT_TEST 33/33 pass.
@vuule

vuule commented Jun 10, 2026

Copy link
Copy Markdown
Owner Author

Closing: re-doing this as a proper stacked PR via gh stack (the fork-internal base was not the intended mechanism).

@vuule vuule closed this Jun 10, 2026
@vuule vuule reopened this Jun 11, 2026
Reject out-of-range "[N]" indices at parse time (std::from_chars bound
to cudf::size_type) and accumulate the index in uint64_t on the GPU path
walker to avoid signed-int32 overflow (UB). Add a SyntaxErrors case for an
over-long index, document that out-of-range indices throw, and note that
array element offsets are monotonic (unlike object field offsets).
@vuule vuule changed the title Add array-index ("[N]") support to VARIANT field extraction Add array-index support to Parquet variant field extraction Jun 15, 2026
@vuule vuule closed this Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant